#include "sd_spi.h"


// This code is from http://www.societyofrobots.com/robotforum/index.php?topic=7231.0


spi_init(void){
  unsigned char a;

  DDRB |= (1<<MOSI)|(1<<SCK)|(1<<SS);
  DDRB &= ~(1<<MISO);
  PORTB |= (1<<SS);//set SS high
  PORTB &= ~(1<<MISO);//turn off internal pullup for MISO
  PORTB &= ~(1<<MOSI);//pull MOSI low
  PORTB &= ~(1<<SCK);//pull SCK low

  //setup registers
  SPSR = 0b00000000;//see datasheet
  SPCR = 0b01010000;//see datasheet
 
  //clear out any junk in SPI buffer
  a = SPSR;
}

